	<!DOCTYPE html>
	<html>
		<head>
			<meta charset="UTF-8">
			<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
			<title>质检列表</title>
			<link rel="stylesheet" href="css/AllStyle.css" />
			<link rel="stylesheet" href="css/iconfont.css" />
			<script type="text/javascript" src="js/common.js" ></script>
			<script type="text/javascript" src="js/companydata.js" ></script>
			<script type="text/javascript" src="js/data.js" ></script>
			<script type="text/javascript" src="js/tmpl.js" ></script>
		</head>
		<body>
			<section>
				<script type="text/javascript">
					AllPageHeader()
				</script>
			</section>

			<section class="AllContent" id="pullrefresh" style="background-color: #fff;">
				<section>
					<form>
						<div class="FormStyle">
							<div class="ScanInput" style="width:90%;margin:10px auto;">
								<p style="margin: 0px;"><input name="qualityNo" id="qualityNo" class="bg-focus form-control" type="text" placeholder="工程名称,工序名称,质检编号"></p>
								<p style="margin: 0px;"><button type="button" style="font-size:0.9em" onclick="querySend();">查询</button></p>
							</div>
							<p class="TheResults" style="margin:0px 5%;padding:0px;padding-bottom:10px;"></p>
							<div class=""><p class="relative alert alert-success"></p></div>
						</div>

						<div class="grid-body" id="cententbody"></div>
					</form>

					<div id="sendList" style="background-color: #fff;">
						<img style="width: 40%;margin:20px auto;display: block;" src="images/loading5.gif">
					</div>
				</section>
			</section>

			<div id="dddd"></div>
		</body>
		<script type="text/javascript" src="js/jquery.min.js" ></script>
		<script>var h5pullDown = true;</script>
		<script type="text/javascript" src="js/mui.js" ></script>
		<script type="text/javascript" src="js/mui.pullToRefresh.js"></script>
		<script type="text/javascript" src="js/mui.pullToRefresh.material.js"></script>
		<script type="text/javascript">
			let pageNo = 0;
			let pageSize = 20; //页数大小
			let totalPages = 1;
			mui.init({
				pullRefresh: {
					container: '#pullrefresh',
					down: {
						contentdown : "<div style='text-align:center;fonr-size:0.95em;color:#ccc;'>下拉刷新</div>",
						contentover : '<div style="width:100%;background:#fff;"><img style="width: 20%;margin:0px auto;display:block;" src="images/loading5_.jpg" /><p style="text-align:center;color:#777;padding:5px 0px;">释放加载...</p></div>',
						contentrefresh : '<div style="width:100%;background:#fff;"><img style="width: 20%;margin:0px auto;display:block;" src="images/loading5.gif" /><p style="text-align:center;color:#777;padding:5px 0px;">正在加载...</p></div>',
						callback: function () {
							let self = this;
							pageNo = 1;
							setTimeout(function() {
								querySend("down",self);
							},100);
						}
					},
					up: {
						contentrefresh: "<div style='text-align:center;fonr-size:0.95em;color:#ccc;'>正在加载...</div>",
						contentnomore: "<div style='text-align:center;fonr-size:0.95em;color:#ccc;'>没有更多质检信息了</div>",
						auto: true,
						callback: function() {
							var self = this;
							pageNo = pageNo + 1;
							setTimeout(function() {
								if(pageNo <= totalPages){
									querySend("up",self);
								}
							}, 100);
						}
					}
				}
			});


			$('.AllHeader li:eq(1)').text("我的质检列表");
			$('.AllHeader li:eq(2)').html('<img style="width:28px" src="images/Scan.png">')

			mui.plusReady(function(){
				//扫描器
				document.getElementById('Scanner').addEventListener('tap', function() {
				  mui.openWindow({
					url: 'Scanner.html?etk=8',
					id:'Scanner.html'
				  });
				});
			});

			//添加refresh自定义事件监听
			window.addEventListener('myQualityList',function(){
				var id = event.detail.id;
				$('#qualityNo').val(id);
				pageNo = 1;
				querySend("other",this);
			});

			//搜索客户发货单
			$(".serarchBtn").on('tap',function(){
			  querySend("down",this);
			});

			$(function(){
				if(getCookie("token") === null || getCookie("token") === ''){
					window.location.href='login.html';
					return;
				}
			});

			function querySend(type,obj) {
				var qualityNo = $("#qualityNo").val();
				var myData = {'pageSize':pageSize,'pageNo':pageNo};
				if(qualityNo !== undefined && qualityNo !== ''){
					myData = {'qualityNo':qualityNo,'pageSize':pageSize,'pageNo':pageNo};
				}
				let loaded = false;
				$.ajax({
					headers:{
						"X-Access-Token":getCookie("token")
					},
					type: "GET",
					url: getServerUrl()+"/quality/qualityTesting/myPhoneQuality", //与此php页
					dataType: 'json', //从php返回的值以 JSON方式 解释
					contentType: 'application/json',
					data: myData,
					success: function (json) {
						if(loaded){
							return;
						}
						sendlist = json.result.records;
						var chtml = '';
						if (!empty(sendlist)) {
							for (var i = 0; i < sendlist.length; i++) {
								if (!empty(sendlist[i])) {
									chtml = chtml + '<li class="list" ext_id="'+ sendlist[i].id +'" ext_quality_no="'+ sendlist[i].qualityNo +'">';
									chtml = chtml + '<div class="ProductsListContent">';
									chtml = chtml + '<div class="ProductsDetails">';
									chtml = chtml + '<p>工程名称：' + sendlist[i].engineName + '</p>';
									chtml = chtml + '<p>工序名称：' + sendlist[i].procName + '</p>';
									chtml = chtml + '<p>质检单号：' + sendlist[i].qualityNo + '</p>';
									chtml = chtml + '<p>质检时间：' + sendlist[i].createTime + '</p>';
									chtml = chtml + '<p>合格数量：' + sendlist[i].qualifiedCount + '</p>';
									chtml = chtml + '<span style="width: 100%;padding-top:10px;height:40px;margin-top:10px;background-color:#00a9ed;float:left;color:#ffffff;text-align:center;font-size:20px;">撤回质检</span>';
									chtml = chtml + '</li>';
									chtml = chtml + '</ul>';
									chtml = chtml + '</div>';
									chtml = chtml + '</div>';
								}
							}
						}
						if(pageNo === 1){
							$("#sendList").html(chtml);
						}else{
							$("#sendList").append(chtml);
						}
						pageNo = json.result.current;
						totalPages = json.result.pages;
						if ((pageNo === totalPages || totalPages === 0) && type === 'up'){
							obj.endPullupToRefresh(true);
						}
						showpage(json.total_results,json.page_no,json.page_size,getwindowhref());
						if (type !== undefined && type !== null && obj !== undefined && obj !== null){
							if (type === 'up'){
								if(pageNo < totalPages){
									obj.endPullupToRefresh();
								}else{
									obj.endPullupToRefresh(true);
								}
							}else if (type === 'down'){
								obj.endPulldownToRefresh();
							}
						}
					},
					error: function () {
					}
				});
			}
			mui('body').on('tap', '.list', function() {
				var id = $(this).attr('ext_id');
				var qualityNo = $(this).attr('ext_quality_no');
				let btnArray = ['取消', '确定'];

				mui.confirm('你确定要撤回 '+qualityNo+' 的质检数据吗？','撤回质检提示', btnArray, function(e) {
					if (e.index == 1) {
						$.ajax({
							headers:{
								"X-Access-Token":getCookie("token")
							},
							type: "post",
							url: getServerUrl()+"/quality/qualityTesting/returnQuality",
							data: {'id':id},
							success: function (json) {
								querySend();
							},
							error: function () {
							}
						});
					}
				});
			});
			mui('body').on('tap', '.myFirstPage', function() {
				mui.openWindow({
					url:'supper.html',
					id:'supper.html',
				})
			});
		</script>
		<style>
			p{
				margin-top: 10px;
				color: #AAAAAA;
			}
		</style>
	</html>
